
<%@page import="qldc.pm.qtht.dmdc.service.QuanHeGiaDinhLocalServiceUtil"%>
<%@page import="qldc.pm.qtht.dmdc.model.QuanHeGiaDinh"%>
<%@page import="qldc.pm.qtht.dmdc.service.DanTocLocalServiceUtil"%>
<%@page import="qldc.pm.qtht.dmdc.model.DanToc"%>
<%@page import="qldc.pm.qtht.dmdc.service.TonGiaoLocalServiceUtil"%>
<%@page import="qldc.pm.qtht.dmdc.model.TonGiao"%>
<%@page import="com.liferay.portal.kernel.util.Constants"%>
<%@page import="qldc.pm.qlktcsdldc.actions.ActionHandlerConstant"%>
<%@page import="qldc.pm.qtht.dmdc.service.TinhLocalServiceUtil"%>
<%@page import="qldc.pm.qtht.dmdc.model.Tinh"%>
<%@page import="qldc.pm.qlktcsdldc.emun.ThongTinThayDoiEnum"%>
<%@page import="qldc.pm.qtht.dmdc.utils.DiaChiUtils"%>
<%@page import="qldc.pm.csdl.cd90.service.CongDanDTOLocalServiceUtil"%>
<%@page import="qldc.pm.csdl.cd90.model.dto.CongDanDTO"%>
<%@ include file="../init.jsp"%>

<%
	String soDinhDanhCaNhan = ParamUtil.getString(request, "soDinhDanhCaNhan");
	System.out.println("soDinhDanhCaNhan: >>>"+soDinhDanhCaNhan);
	String pathThemeImages = themeDisplay.getPathThemeImages();
	
	CongDanDTO congDanDTO = null;
	String _hoVaTen = "";
	String _soCMND ="";
	String _diaChiThuongTru ="";
	
	if(Validator.isNotNull(soDinhDanhCaNhan)){
		congDanDTO = CongDanDTOLocalServiceUtil.findBySoDinhDanhCaNhan(soDinhDanhCaNhan);
		if(Validator.isNotNull(congDanDTO)){
			_hoVaTen = congDanDTO.getHoVaTen();
			_soCMND = congDanDTO.getSoCMND();
			_diaChiThuongTru = DiaChiUtils.createBlockDiaChi(congDanDTO.getNoiThuongTruTinhId(), congDanDTO.getNoiThuongTruQuanHuyenId(), congDanDTO.getNoiThuongTruPhuongXaId(), congDanDTO.getNoiThuongTruDiaChi());

		}
	}
	
	String redirectURL = ParamUtil.getString(request, "redirect");
	
	PortletURL backURL = renderResponse.createRenderURL();
	backURL.setParameter("mvcPath", "/html/qlktcsdldc/quan_ly_dan_cu.jsp");
	backURL.setParameter("tabs1", QLKTCSDLDCContants.PAGEID_QLDC_MAN_HINH_CHINH);
	backURL.setParameter("redirect", redirectURL);
	
	List<Tinh> tinhs = TinhLocalServiceUtil.findAll();
%>

<portlet:resourceURL var="loadQuanHuyen" id="loadQuanHuyen">
	<portlet:param name="tinhIdSelected" value="{0}" />
</portlet:resourceURL>

<portlet:resourceURL var="loadPhuongXa" id="loadPhuongXa">
	<portlet:param name="quanHuyenIdSelected" value="{0}" />
</portlet:resourceURL>

<portlet:resourceURL var="onChangeThongTinThayDoi" id="onChangeThongTinThayDoi">
	<portlet:param name="soDinhDanhCaNhan" value="{0}" />
	<portlet:param name="thongTinThayDoiId" value="{1}" />
</portlet:resourceURL>

<portlet:actionURL var="suaThongTinSaveURL">
	<portlet:param name="<%=ActionHandlerConstant.ACTION_HANDLER_PARAM%>" value="<%=ActionHandlerConstant.QUAN_LY_DAN_CU_ACTION%>" />
	<portlet:param name="<%=Constants.ACTION%>" value="suaThongTinSave" />
	<portlet:param name="soDinhDanhCaNhan" value="<%=soDinhDanhCaNhan %>"/>
	<portlet:param name="redirect" value="<%=redirectURL%>" />
</portlet:actionURL>

<portlet:renderURL var="suaThongTinThoatURL" windowState="<%= String.valueOf(WindowState.NORMAL) %>">
	<portlet:param name="mvcPath" value="/html/qlktcsdldc/quan_ly_dan_cu.jsp" />
	<portlet:param name="tabs1" value="<%= QLKTCSDLDCContants.PAGEID_QLDC_MAN_HINH_CHINH %>"/>
</portlet:renderURL>

<h2 class="tle-Content">
	<liferay-ui:message key="sua-tt-cong-dan" />
</h2>
<div class="main-Content">
	<form name="<portlet:namespace/>fmSuaThongTin" id="<portlet:namespace/>fmSuaThongTin" method="POST" action="" onsubmit="return false;">
		<%
			long thongTinThayDoiId = ParamUtil.getLong(request, "suaThongTinThayDoi");
			long tinhId = ParamUtil.getLong(request, "tinh");
			long quanHuyenId = ParamUtil.getLong(request, "quanHuyen");
			long phuongXaId = ParamUtil.getLong(request, "phuongXa");
			String dCThuongTru = ParamUtil.getString(request, "dCThuongTru");
		%>
		<table class="gridnormal">
			<tr>
				<td>
					<liferay-ui:message key="so-dinh-danh-ca-nhan" />
				</td>
				<td>
					<%=soDinhDanhCaNhan %>
				</td>
			</tr>

			<tr>
				<td>
					<liferay-ui:message key="ho-ten" />
				</td>
				<td>
					<%=_hoVaTen %>
				</td>
			</tr>

			<tr>
				<td>
					<liferay-ui:message key="so-cmnd" />
				</td>
				<td>
					<%=_soCMND %>
				</td>
			</tr>

			<tr>
				<td>
					<liferay-ui:message key="dc-thuong-tru" />
				</td>
				<td>
					<%=_diaChiThuongTru %>
				</td>
			</tr>

			<tr>
				<td>
					<liferay-ui:message key="truong-tt-can-redo" />
				</td>
				
				<td>
					<select class=""  id="<portlet:namespace/>suaThongTinThayDoi"  name="<portlet:namespace/>suaThongTinThayDoi" onchange="onChangeSuaThongTinThayDoi()">
						<%
							for(ThongTinThayDoiEnum thongTinThayDoiEnum : ThongTinThayDoiEnum.values()){
						%>
							<option value="<%=thongTinThayDoiEnum.getValue()%>"
							<%=(thongTinThayDoiEnum.getValue() == thongTinThayDoiId) ? "selected=selected" : ""%>><%=LanguageUtil.get(portletConfig, request.getLocale(), thongTinThayDoiEnum.getKey())%></option>
						<%
							} 
						%>
					</select>
				</td>
			</tr>
			<tr>
				<td>
					<liferay-ui:message key="gia-tri-cu" />
				</td>
				<td>
					<input type="text" readonly="readonly" name="<portlet:namespace/>giaTriCu" id="<portlet:namespace/>giaTriCu" />
				</td>
			</tr>

			<tr id="<portlet:namespace/>type_input">
				<td>
					<liferay-ui:message key="gia-tri-moi" />
				</td>
				<td>
					<input type="text"  name="<portlet:namespace/>typeInputValue" id="<portlet:namespace/>typeInputValue" />
				</td>
			</tr>
			
			<tr id="<portlet:namespace/>type_address">
				<td>
					<liferay-ui:message key="gia-tri-moi" />
				</td>
				<td>
					<select class=""  id="<portlet:namespace/>tinh"  name="<portlet:namespace/>tinh" 
					onchange="loadNewQuanHuyen('<portlet:namespace />','<%=loadQuanHuyen.toString()%>',<%=quanHuyenId%>,'tinh','quanHuyen', 'phuongXa');">
						<option value="0"><liferay-ui:message key="chon-tinh" /></option>
						<%
							for (Tinh tinh : tinhs) {
						%>
						<option value="<%=tinh.getTinhId()%>"
							<%=tinh.isLaMacDinh() ? "selected=selected" : ""%>><%=tinh.getTenTinh()%></option>
						<%
							}
						%>
					</select>
					<select class=""  id="<portlet:namespace/>quanHuyen"  name="<portlet:namespace/>quanHuyen" 
						onchange="loadNewPhuongXa('<portlet:namespace />','<%=loadPhuongXa.toString()%>',<%=phuongXaId%>,'tinh','quanHuyen', 'phuongXa');">
						<option value="0"><liferay-ui:message key="chon-quan-huyen" /></option>
					</select>
					<select class=""  id="<portlet:namespace/>phuongXa"  name="<portlet:namespace/>phuongXa">
						<option value="0"><liferay-ui:message key="chon-phuong-xa" /></option>
					</select>
					<input type="text" name="<portlet:namespace/>diaChi" id="<portlet:namespace/>diaChi" value="" />
				</td>
			</tr>
			<tr id="<portlet:namespace/>type_danToc">
				<td>
					<liferay-ui:message key="gia-tri-moi" />
				</td>
				<td>
					<select readonly="readonly" name="<portlet:namespace />danToc" id="<portlet:namespace />danToc">
						<option value="0"><liferay-ui:message key="chon-dan-toc" /></option>
						<%
							List<DanToc> danTocs = DanTocLocalServiceUtil.findAll();
							for (DanToc danToc : danTocs) {
						%>
						<option value="<%=danToc.getDanTocId()%>"><%=danToc.getTenDanToc()%></option>
						<%
							}
						%>
					</select>
				</td>
			</tr>
			<tr id="<portlet:namespace/>type_tonGiao">
				<td>
					<liferay-ui:message key="gia-tri-moi" />
				</td>
				<td>
					<select  readonly="readonly" name="<portlet:namespace />tonGiao" id="<portlet:namespace />tonGiao">
						<option value="0"><liferay-ui:message key="chon-ton-giao" /></option>
						<%
							List<TonGiao> tonGiaos = TonGiaoLocalServiceUtil.findAll();
							for (TonGiao tonGiao : tonGiaos) {
						%>
						<option value="<%=tonGiao.getTonGiaoId()%>"><%=tonGiao.getTenTonGiao()%></option>
						<%
							}
						%>
					</select>
				</td>
			</tr>
			<tr id="<portlet:namespace/>type_quanHeVoiChuHo">
				<td>
					<liferay-ui:message key="gia-tri-moi" />
				</td>
				<td>
					<select  readonly="readonly" name="<portlet:namespace />quanHeVoiChuHo" id="<portlet:namespace />quanHeVoiChuHo">
						<option value="0"><liferay-ui:message key="chon-quan-he-chu-ho" /></option>
						<%
							List<QuanHeGiaDinh> quanHeGiaDinhs = QuanHeGiaDinhLocalServiceUtil.findAll();
							for (QuanHeGiaDinh quanHeGiaDinh : quanHeGiaDinhs) {
						%>
						<option value="<%=quanHeGiaDinh.getQuanHeGiaDinhId()%>"><%=quanHeGiaDinh.getTenQuanHeGiaDinh()%></option>
						<%
							}
						%>
					</select>
				</td>
			</tr>
			<tr id="<portlet:namespace/>type_gioiTinh">
				<td>
					<liferay-ui:message key="gia-tri-moi" />
				</td>
				<td>
					<select class=""  id="<portlet:namespace/>gioiTinh"  name="<portlet:namespace/>gioiTinh">
						<option value="0"><liferay-ui:message key="nu" /></option>
						<option value="1"><liferay-ui:message key="nam" /></option>		
					</select>			
				</td>
			</tr>
			<tr id="<portlet:namespace/>type_date">
				<td>
					<liferay-ui:message key="gia-tri-moi" />
				</td>
				<td class="aui-w30 ip-datepicker">
					<input type="text"  name="<portlet:namespace/>typeDateValue" id="<portlet:namespace/>typeDateValue" />
				</td>
			</tr>
			<tr>
				<td colspan="2">
					<input type="submit" class="" onclick="suaThongTinSave()" value="<liferay-ui:message key="luu" />" id="<portlet:namespace/>luu" /> 
					<input type="submit" class="" onclick="suaThongTinThoat()" value="<liferay-ui:message key="thoat" />"  id="<portlet:namespace/>thoat" />
				</td>
			</tr>
		</table>
	</form>
</div>




<script>
$(document).ready(function() {
	loadNewQuanHuyen('<portlet:namespace />','<%=loadQuanHuyen.toString()%>',<%=quanHuyenId%>,'tinh','quanHuyen', 'phuongXa');
	loadNewPhuongXa('<portlet:namespace />','<%=loadPhuongXa.toString()%>',<%=phuongXaId%>,'tinh','quanHuyen', 'phuongXa');
	
	$("#<portlet:namespace/>typeDateValue").datepicker({
		showOn: "both",
		buttonImage: "<%=pathThemeImages%>/common/calendar.png",
		buttonImageOnly: true,
		buttonText: "<liferay-ui:message key="ngay" />",
		dateFormat: "dd/mm/yy"
	});
	
	var typeInput =  $('#<portlet:namespace/>type_input');
	var typeAddress =  $('#<portlet:namespace/>type_address');
	var typeGioiTinh =  $('#<portlet:namespace/>type_gioiTinh');
	var typeDate =  $('#<portlet:namespace/>type_date');
	var typeTonGiao =  $('#<portlet:namespace/>type_tonGiao');
	var typeDanToc =  $('#<portlet:namespace/>type_danToc');
	var typeQuanHeVoiChuHo =  $('#<portlet:namespace/>type_quanHeVoiChuHo');
	
	console.log("sua thong tin initialize typeInput"); 
	typeInput.removeClass('hidden');
	typeAddress.addClass('hidden');
	typeGioiTinh.addClass('hidden');
	typeDate.addClass('hidden');
	typeTonGiao.addClass('hidden');
	typeDanToc.addClass('hidden');
	typeQuanHeVoiChuHo.addClass('hidden');
});


function validatonFormSuaThongTin(){
	
	var giaTriCu = $("#<portlet:namespace/>giaTriCu");
	if(giaTriCu && $.trim(giaTriCu.val()) == ""){
		showPopupConfirm('<liferay-ui:message key="khong-tim-thay-gia-tri-cu" />',['Ok'],function(index){
			giaTriCu.focus();				
		});
	}
	var thongTinThayDoi = $("#<portlet:namespace/>suaThongTinThayDoi");
	if(thongTinThayDoi && $.trim(thongTinThayDoi.val()) != "0"){
		if(thongTinThayDoi.val() === '<%=ThongTinThayDoiEnum.QUEQUAN.getValue() %>' ||
			thongTinThayDoi.val() === '<%=ThongTinThayDoiEnum.THUONGTRU.getValue() %>' ||
			thongTinThayDoi.val() === '<%=ThongTinThayDoiEnum.NOIOHIENTAI.getValue() %>' ||
			thongTinThayDoi.val() === '<%=ThongTinThayDoiEnum.NOILAMVIEC.getValue() %>' ||
			thongTinThayDoi.val() === '<%=ThongTinThayDoiEnum.ODAUDEN.getValue() %>'||
			thongTinThayDoi.val() === '<%=ThongTinThayDoiEnum.CHUYENDIDAU.getValue() %>'){
			var tinh = $("#<portlet:namespace/>tinh");
			if(!tinh || $.trim(tinh.val()) == "0"){
				showPopupConfirm('<liferay-ui:message key="xin-vui-long-nhap-thong-tin" />  : [<liferay-ui:message key="tinh" />]',['Ok'],function(index){
					tinh.focus();				
				});
				return false;
			}
			var quanHuyen = $("#<portlet:namespace/>quanHuyen");
			if(!quanHuyen || $.trim(quanHuyen.val()) == "0"){
				showPopupConfirm('<liferay-ui:message key="xin-vui-long-nhap-thong-tin" />  : [<liferay-ui:message key="tinh" />]',['Ok'],function(index){
					quanHuyen.focus();				
				});
				return false;
			}
			var phuongXa = $("#<portlet:namespace/>phuongXa");
			if(!phuongXa || $.trim(phuongXa.val()) == "0"){
				showPopupConfirm('<liferay-ui:message key="xin-vui-long-nhap-thong-tin" />  : [<liferay-ui:message key="phuong-xa" />]',['Ok'],function(index){
					phuongXa.focus();				
				});
				return false;
			}
			var dCThuongTru = $("#<portlet:namespace/>diaChi");
			if(!dCThuongTru || $.trim(dCThuongTru.val()) == ""){
				showPopupConfirm('<liferay-ui:message key="xin-vui-long-nhap-thong-tin" />  : [<liferay-ui:message key="dia-chi" />]',['Ok'],function(index){
					dCThuongTru.focus();				
				});
				return false;
			}

		}else if(thongTinThayDoi.val() === '<%=ThongTinThayDoiEnum.NTNSINH.getValue() %>' ||
			thongTinThayDoi.val() === '<%=ThongTinThayDoiEnum.NGAYDEN.getValue() %>' ||
			thongTinThayDoi.val() === '<%=ThongTinThayDoiEnum.NGAYCHUYEN.getValue()%>'){
			var typeDateValue = $("#<portlet:namespace/>typeDateValue");
			if(!typeDateValue || $.trim(typeDateValue.val()) == ""){
				showPopupConfirm('<liferay-ui:message key="xin-vui-long-nhap-thong-tin" />  : [<liferay-ui:message key="ngay" />]',['Ok'],function(index){
					typeDateValue.focus();				
				});
				return false;
			}
		}else if(thongTinThayDoi.val() === '<%=ThongTinThayDoiEnum.GIOITINH.getValue() %>'){
			return true;	
		}else if(thongTinThayDoi.val() === '<%=ThongTinThayDoiEnum.TONGIAO.getValue() %>'){
			var tonGiao = $("#<portlet:namespace/>tonGiao");
			if(!tonGiao || $.trim(tonGiao.val()) == "0"){
				showPopupConfirm('<liferay-ui:message key="xin-vui-long-nhap-thong-tin" />  : [<liferay-ui:message key="ton-giao" />]',['Ok'],function(index){
					tonGiao.focus();				
				});
				return false;
			}	
		}else if(thongTinThayDoi.val() === '<%=ThongTinThayDoiEnum.DANTOC.getValue() %>'){
			var danToc = $("#<portlet:namespace/>danToc");
			if(!danToc || $.trim(danToc.val()) == "0"){
				showPopupConfirm('<liferay-ui:message key="xin-vui-long-nhap-thong-tin" />  : [<liferay-ui:message key="dan-toc" />]',['Ok'],function(index){
					danToc.focus();				
				});
				return false;
			}	
		}else if(thongTinThayDoi.val() === '<%=ThongTinThayDoiEnum.QUANHECHUHO.getValue() %>'){
			var quanHeVoiChuHo = $("#<portlet:namespace/>quanHeVoiChuHo");
			if(!quanHeVoiChuHo || $.trim(quanHeVoiChuHo.val()) == "0"){
				showPopupConfirm('<liferay-ui:message key="xin-vui-long-nhap-thong-tin" />  : [<liferay-ui:message key="quan-he-chu-ho" />]',['Ok'],function(index){
					quanHeVoiChuHo.focus();				
				});
				return false;
			}	
		}else{ //Type input 
			var typeInputValue = $("#<portlet:namespace/>typeInputValue");
			if(!typeInputValue || $.trim(typeInputValue.val()) == ""){
				showPopupConfirm('<liferay-ui:message key="xin-vui-long-nhap-thong-tin" />  : [<liferay-ui:message key="gia-tri-moi" />]',['Ok'],function(index){
					typeInputValue.focus();				
				});
				return false;
			}
		}
	}	
	return true;
};
function onChangeSuaThongTinThayDoi(){
	console.log("onChangeSuaThongTinThayDoi"); 
	var thongTinThayDoi = $("#<portlet:namespace/>suaThongTinThayDoi");
	
	var typeInput =  $('#<portlet:namespace/>type_input');
	var typeAddress =  $('#<portlet:namespace/>type_address');
	var typeGioiTinh =  $('#<portlet:namespace/>type_gioiTinh');
	var typeDate =  $('#<portlet:namespace/>type_date');
	var typeTonGiao =  $('#<portlet:namespace/>type_tonGiao');
	var typeDanToc =  $('#<portlet:namespace/>type_danToc');
	var typeQuanHeVoiChuHo =  $('#<portlet:namespace/>type_quanHeVoiChuHo');
	console.log("onChangeSuaThongTinThayDoi value:"+ thongTinThayDoi.val());
	if(thongTinThayDoi.val() === '<%=ThongTinThayDoiEnum.QUEQUAN.getValue() %>' ||
		thongTinThayDoi.val() === '<%=ThongTinThayDoiEnum.THUONGTRU.getValue() %>' ||
		thongTinThayDoi.val() === '<%=ThongTinThayDoiEnum.NOIOHIENTAI.getValue() %>' ||
		thongTinThayDoi.val() === '<%=ThongTinThayDoiEnum.NOILAMVIEC.getValue() %>' ||
		thongTinThayDoi.val() === '<%=ThongTinThayDoiEnum.ODAUDEN.getValue() %>'||
		thongTinThayDoi.val() === '<%=ThongTinThayDoiEnum.NOISINH.getValue() %>'||
		thongTinThayDoi.val() === '<%=ThongTinThayDoiEnum.CHUYENDIDAU.getValue() %>'){
		console.log("onChangeSuaThongTinThayDoi typeAddress"); 
			typeInput.addClass('hidden');
			typeAddress.removeClass('hidden');
			typeGioiTinh.addClass('hidden');
			typeDate.addClass('hidden');
			typeTonGiao.addClass('hidden');
			typeDanToc.addClass('hidden');
			typeQuanHeVoiChuHo.addClass('hidden');
			
	}else if(thongTinThayDoi.val() === '<%=ThongTinThayDoiEnum.NTNSINH.getValue() %>' ||
		thongTinThayDoi.val() === '<%=ThongTinThayDoiEnum.NGAYDEN.getValue() %>' ||
		thongTinThayDoi.val() === '<%=ThongTinThayDoiEnum.NGAYCHUYEN.getValue()%>'){
			console.log("onChangeSuaThongTinThayDoi typeDate"); 
			typeInput.addClass('hidden');
			typeAddress.addClass('hidden');
			typeGioiTinh.addClass('hidden');
			typeDate.removeClass('hidden');
			typeTonGiao.addClass('hidden');
			typeDanToc.addClass('hidden');
			typeQuanHeVoiChuHo.addClass('hidden');
	}else if(thongTinThayDoi.val() === '<%=ThongTinThayDoiEnum.GIOITINH.getValue() %>'){
		console.log("onChangeSuaThongTinThayDoi typeGioiTinh"); 
		typeInput.addClass('hidden');
		typeAddress.addClass('hidden');
		typeGioiTinh.removeClass('hidden');
		typeDate.addClass('hidden');
		typeTonGiao.addClass('hidden');
		typeDanToc.addClass('hidden');
		typeQuanHeVoiChuHo.addClass('hidden');
	}else if(thongTinThayDoi.val() === '<%=ThongTinThayDoiEnum.TONGIAO.getValue() %>'){
		console.log("onChangeSuaThongTinThayDoi typeTonGiao"); 
		typeInput.addClass('hidden');
		typeAddress.addClass('hidden');
		typeGioiTinh.addClass('hidden');
		typeDate.addClass('hidden');
		typeTonGiao.removeClass('hidden');
		typeDanToc.addClass('hidden');
		typeQuanHeVoiChuHo.addClass('hidden');
	}else if(thongTinThayDoi.val() === '<%=ThongTinThayDoiEnum.DANTOC.getValue() %>'){
		console.log("onChangeSuaThongTinThayDoi typeDanToc"); 
		typeInput.addClass('hidden');
		typeAddress.addClass('hidden');
		typeGioiTinh.addClass('hidden');
		typeDate.addClass('hidden');
		typeTonGiao.addClass('hidden');
		typeDanToc.removeClass('hidden');
		typeQuanHeVoiChuHo.addClass('hidden');
	}else if(thongTinThayDoi.val() === '<%=ThongTinThayDoiEnum.QUANHECHUHO.getValue() %>'){
		console.log("onChangeSuaThongTinThayDoi typeQuanHeVoiChuHo"); 
		typeInput.addClass('hidden');
		typeAddress.addClass('hidden');
		typeGioiTinh.addClass('hidden');
		typeDate.addClass('hidden');
		typeTonGiao.addClass('hidden');
		typeDanToc.addClass('hidden');
		typeQuanHeVoiChuHo.removeClass('hidden');
	}else{
		console.log("onChangeSuaThongTinThayDoi typeInput"); 
		typeInput.removeClass('hidden');
		typeAddress.addClass('hidden');
		typeGioiTinh.addClass('hidden');
		typeDate.addClass('hidden');
		typeTonGiao.addClass('hidden');
		typeDanToc.addClass('hidden');
		typeQuanHeVoiChuHo.addClass('hidden');
	}
	
	console.log("onChangeSuaThongTinThayDoi thongTinThayDoi: "+thongTinThayDoi.val()); 
	if(thongTinThayDoi && $.trim(thongTinThayDoi.val()) != "0"){
		var thongTinThayDoiId = thongTinThayDoi.val();
		var soDDCN = '<%= soDinhDanhCaNhan.toString() %>';
		console.log("onChangeSuaThongTinThayDoi soDDCN : "+soDDCN);
		var urlThongTinThayDoi =  '<%= onChangeThongTinThayDoi.toString() %>';
		urlThongTinThayDoi = urlThongTinThayDoi.replace(/%7B0%7D/g, function() {
			return soDDCN;
		});
		urlThongTinThayDoi = urlThongTinThayDoi.replace(/%7B1%7D/g, function() {
			return thongTinThayDoiId;
		});
		jQuery.ajax({
			url : urlThongTinThayDoi,
			dataType : 'json',
			type : "POST",
			cache : false,
			timeout : 10000,
			async : false,
			success : function(data) {
				if(data != null){
					$("#<portlet:namespace/>giaTriCu").val(data.giaTriCu);
				}else{
					alert('<liferay-ui:message key="khong-tim-thay-gia-tri-cu" />');
				}
			},
			error : function(xhr, textStatus, errorThrown) {
				alert(textStatus);
			}
		});
	}
};


function suaThongTinSave(){
	console.log("suaThongTinSave: "); 
	if(validatonFormSuaThongTin()){
		showPopupConfirm('<liferay-ui:message key="ban-co-muon-luu-thong-tin" />',['Yes','No'],function(index){
			if (index == 0){
				var url = '<%=suaThongTinSaveURL.toString()%>';
				$("#<portlet:namespace/>fmSuaThongTin").attr('action', url);
				$("#<portlet:namespace/>fmSuaThongTin").attr('onsubmit', 'return true;');
				$("#<portlet:namespace/>fmSuaThongTin").submit(); 
			}
		});	
	} 
	
};
function suaThongTinThoat(){
	console.log("suaThongTinThoat: "); 
	location.href = '<%=suaThongTinThoatURL.toString()%>';
};
</script>